package com.frame.pageform;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.frame.util.SelectItem;
import com.sun.star.awt.Selection;


/**
 * @Title: 系统
 * @Description:
 * @Copyright: Copyright (c) 2015
 * @Company:
 * @author 王海锋
 * @CreatedTime:2015-8-28 下午10:50:51
 * @version 1.0
 */

public class UrlWriteConfig {

    private List<SelectItem> urlList=new ArrayList<SelectItem>();;

    public static UrlWriteConfig getInstance(){
        try
        {
            return (UrlWriteConfig)ConfigFactory.getBean(UrlWriteConfig.class);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
        return null;
    }

    public String patternUrl(String url){
        for(SelectItem item:urlList){
            try{
                Pattern pattern=Pattern.compile(item.getValue());
                Matcher u_m = pattern.matcher(url);
                if(u_m.find()){
                    return item.getText();
                }
            }catch(Exception e){}
        }
        return null;
    }

    public void addUrlPattern(String url,String urlclass){
        urlList.add(new SelectItem(url,urlclass));
    }
}
